// ml:run = $bin < input
// ml:opt = 0
// ml:ccf += -g
#include <iostream>
#include <cstring>

using ll = long long;

ll l, r;
int a[30];
int b[30];
//      less  odd  even  current odd
ll f[35][2][35][35][2];

ll calc2(ll x)
{
    if (!x) return 1;
    std::memset(a, 0, sizeof(a));
    std::memset(f, 0, sizeof(f));
    int len = 0;
    auto tmp = x;
    for (; tmp; tmp /= 10) b[len++] = tmp % 10;
    for (int i = 0; i < len; i++) a[len - i - 1] = b[i];

    for (int i = 1; i < a[0]; i++) f[0][0][i & 1][!(i & 1)][i & 1] += 1;
    f[0][1][a[0] & 1][!(a[0] & 1)][a[0] & 1] += 1;

    for (int i = 1; i < len; i++) {
        for (int todd = 0; todd < 20; todd++)
            for (int teven = 0; teven < 20; teven++) {
                for (int last = 0; last < 2; last++) {
                    if (f[i - 1][0][todd][teven][last]) {
                        for (int ti = 0; ti < 10; ti++) {
                            if ((ti & 1) == last) {
                                if (ti & 1) f[i][0][todd + 1][teven][ti & 1] += f[i - 1][0][todd][teven][last];
                                else f[i][0][todd][teven + 1][ti & 1] += f[i - 1][0][todd][teven][last];
                            } else {
                                if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                                if (ti & 1) {
                                    f[i][0][1][1][ti & 1] += f[i - 1][0][todd][teven][last];
                                } else {
                                    f[i][0][0][1][ti & 1] += f[i - 1][0][todd][teven][last];
                                }
                            }
                        }
                    }

                    if (f[i - 1][1][todd][teven][last]) {
                        for (int ti = 0; ti < a[i]; ti++) {
                            if ((ti & 1) == last) {
                                if (ti & 1) f[i][0][todd + 1][teven][ti & 1] += f[i - 1][1][todd][teven][last];
                                else f[i][0][todd][teven + 1][ti & 1] += f[i - 1][1][todd][teven][last];
                            } else {
                                if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                                if (ti & 1) f[i][0][1][1][ti & 1] += f[i - 1][1][todd][teven][last];
                                else f[i][0][0][1][ti & 1] += f[i - 1][1][todd][teven][last];
                            }
                        }

                        int ti = a[i];
                        if ((ti & 1) == last) {
                            if (ti & 1) f[i][1][todd + 1][teven][ti & 1] += f[i - 1][1][todd][teven][last];
                            else f[i][1][todd][teven + 1][ti & 1] += f[i - 1][1][todd][teven][last];
                        } else {
                            if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                            if (ti & 1) f[i][1][1][1][ti & 1] += f[i - 1][1][todd][teven][last];
                            else f[i][1][0][1][ti & 1] += f[i - 1][1][todd][teven][last];
                        }
                    }
                }
            }
    }

    ll ret = 0;
    for (int todd = 0; todd < 20; todd += 2) {
        ret += f[len - 1][1][todd][0][0] + f[len - 1][1][todd][0][1]
                + f[len - 1][0][todd][0][0] + f[len - 1][0][todd][0][1];
        for (int teven = 1; teven < 20; teven += 2) {
            ret += f[len - 1][1][todd][teven][0] + f[len - 1][1][todd][teven][1]
                 + f[len - 1][0][todd][teven][0] + f[len - 1][0][todd][teven][1];
        }
    }
    return ret;
}

ll calc(ll x)
{
    if (!x) return 1;
    std::memset(a, 0, sizeof(a));
    std::memset(f, 0, sizeof(f));
    int len = 0;
    auto tmp = x;
    for (; tmp; tmp /= 10) b[len++] = tmp % 10;
    for (int i = 0; i < len; i++) a[len - i - 1] = b[i];

    for (int i = 1; i < a[0]; i++) f[0][0][i & 1][!(i & 1)][i & 1] += 1;
    f[0][1][a[0] & 1][!(a[0] & 1)][a[0] & 1] += 1;

    for (int i = 1; i < len; i++) {
        for (int todd = 0; todd < 20; todd++)
            for (int teven = 0; teven < 20; teven++) {
                for (int last = 0; last < 2; last++) {
                    if (f[i - 1][0][todd][teven][last]) {
                        for (int ti = 0; ti < 10; ti++) {
                            if ((ti & 1) == last) {
                                if (ti & 1) f[i][0][todd + 1][teven][ti & 1] += f[i - 1][0][todd][teven][last];
                                else f[i][0][todd][teven + 1][ti & 1] += f[i - 1][0][todd][teven][last];
                            } else {
                                if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                                if (ti & 1) {
                                    f[i][0][1][1][ti & 1] += f[i - 1][0][todd][teven][last];
                                } else {
                                    f[i][0][0][1][ti & 1] += f[i - 1][0][todd][teven][last];
                                }
                            }
                        }
                    }

                    if (f[i - 1][1][todd][teven][last]) {
                        for (int ti = 0; ti < a[i]; ti++) {
                            if ((ti & 1) == last) {
                                if (ti & 1) f[i][0][todd + 1][teven][ti & 1] += f[i - 1][1][todd][teven][last];
                                else f[i][0][todd][teven + 1][ti & 1] += f[i - 1][1][todd][teven][last];
                            } else {
                                if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                                if (ti & 1) f[i][0][1][1][ti & 1] += f[i - 1][1][todd][teven][last];
                                else f[i][0][0][1][ti & 1] += f[i - 1][1][todd][teven][last];
                            }
                        }

                        int ti = a[i];
                        if ((ti & 1) == last) {
                            if (ti & 1) f[i][1][todd + 1][teven][ti & 1] += f[i - 1][1][todd][teven][last];
                            else f[i][1][todd][teven + 1][ti & 1] += f[i - 1][1][todd][teven][last];
                        } else {
                            if ((todd && (todd & 1)) || (teven && !(teven & 1))) continue;
                            if (ti & 1) f[i][1][1][1][ti & 1] += f[i - 1][1][todd][teven][last];
                            else f[i][1][0][1][ti & 1] += f[i - 1][1][todd][teven][last];
                        }
                    }
                }
            }
    }

    ll ret = 1;
    for (int todd = 0; todd < 20; todd += 2) {
        ret += f[len - 1][1][todd][0][0] + f[len - 1][1][todd][0][1]
                + f[len - 1][0][todd][0][0] + f[len - 1][0][todd][0][1];
        for (int teven = 1; teven < 20; teven += 2) {
            ret += f[len - 1][1][todd][teven][0] + f[len - 1][1][todd][teven][1]
                 + f[len - 1][0][todd][teven][0] + f[len - 1][0][todd][teven][1];
        }
    }
    ll now = 9;
    for (int ti = 0; ti < len - 1; ti++, now = now * 10 + 9) {
        ret += calc2(now);
    }
    return ret;
}

int main()
{
    std::ios::sync_with_stdio(false);
    int T; std::cin >> T;
    for (int ti = 1; ti <= T; ti++) {
        std::cout << "Case #" << ti << ": ";
        ll l, r; std::cin >> l >> r;
        std::cout << calc(r) - calc(l - 1) << "\n";
    }
}

